package dca;

import java.util.ArrayList;

public class Disease implements Comparable<Object> {
	
	private String name;
	private ArrayList<Symptom> symptoms;
	private Cure cure;
	private Severity severity;  //The severity of a disease is that of the most severe symptom.
	
	public Disease(String name,ArrayList<Symptom> symptoms,Cure cure){
		this.name = name;
		this.symptoms = symptoms;
		this.cure = cure;
		
		//Find the most severe symptom and set is as disease severity.
		int highPrir=Integer.MAX_VALUE;		
		for(Symptom s:this.symptoms)
		{
			if(s.getSeverity().getPriority()<highPrir)
			{
				highPrir=s.getSeverity().getPriority();
				this.severity = s.getSeverity();
			}
		}
	}
	
	public String toString(){
		String diseaseString =  name+"\n";
		diseaseString+= this.cure.toString()+"\n";
		for (int i=0;i<symptoms.size();i++){
			diseaseString+=symptoms.get(i).toString().toLowerCase();
			if(i<symptoms.size()-1)
				diseaseString+=",";
		}
		return diseaseString;
	}
	
	public String getName(){
		return this.name;
	}
	
	public ArrayList<Symptom> getSymptoms(){
		return this.symptoms;
	}
	
	public Cure getCure(){
		return this.cure;
	}
	
	public int compareTo(Object anotherObject){
		if(!(anotherObject instanceof Disease))
			throw new ClassCastException("Can only compare diseases to other diaseases");
		Disease anotherDisease = (Disease) anotherObject;
		return this.name.compareToIgnoreCase(anotherDisease.name);
	}
	
	public Severity getSeverity(){
		return this.severity;
	}

}
